package mao.thinkinjava.io;

import java.io.*;

public class OSExecute {
    public void command(String command){
        String s;
        try{
            Process process= new ProcessBuilder(command.split(" ")).start();
            //获得Process输出的和错误。
            BufferedReader in = new BufferedReader(
                    new InputStreamReader(process.getInputStream()));
            BufferedReader err = new BufferedReader(
                    new InputStreamReader(process.getErrorStream()));
            BufferedWriter out = new BufferedWriter(
                    new OutputStreamWriter(process.getOutputStream()));
            while ((s=in.readLine()) != null){
                System.out.println("+++++标准输出++++++");
                System.out.println(s);
            }
            while ((s=err.readLine()) != null) {
                System.out.println("+++++标准错误++++++");
                System.out.println(s);
            }

        }catch (IOException e){
            e.printStackTrace();
        }
    }
    //java的编译器如何当前路径。？？
    public static void main(String[] args) {
        new OSExecute().command("javap .\\com\\mao\\thinkinjava\\OSExecute.class ");
        File file = new File(".");
        System.out.println(file.getAbsolutePath());
        RandomAccessFile s;
    }
}
